repo_transaction_stats: move to a manual implementation
authorLuca BRUNO <luca.bruno@coreos.com>
Wed, 23 Jun 2021 17:12:40 +0000 (17:12 +0000)
committerColin Walters <walters@verbum.org>
Fri, 6 May 2022 16:53:56 +0000 (12:53 -0400)
This moves `RepoTransactionStats` into a manually implemented
source file in order to provide getters to expose relevant
fields.

rust-bindings/rust/conf/ostree.toml
rust-bindings/rust/src/auto/mod.rs
rust-bindings/rust/src/auto/repo_transaction_stats.rs [deleted file]
rust-bindings/rust/src/lib.rs
rust-bindings/rust/src/repo_transaction_stats.rs [new file with mode: 0644]

index f677e6732c1aa9972015665f79702cee77535e00..51189ebbe2659a9308d9110246a7d2cee9bbf420 100644 (file)
@@ -89,6 +89,7 @@ manual = [
     "OSTree.KernelArgs",
     "OSTree.RepoCheckoutAtOptions",
     "OSTree.RepoCheckoutFilter",
+    "OSTree.RepoTransactionStats",
     "OSTree.SysrootWriteDeploymentsOpts",
     "OSTree.SysrootDeployTreeOpts",
 ]
@@ -187,12 +188,6 @@ status = "generate"
     name = "dup"
     ignore = true
 
-[[object]]
-name = "OSTree.RepoTransactionStats"
-status = "generate"
-init_function_expression = "|_ptr| ()"
-clear_function_expression = "|_ptr| ()"
-
 [[object]]
 name = "OSTree.SePolicy"
 status = "generate"
index 128b8b0ba77bbcb3c4365a34fcf84bb8a217a533..09eb3089e37fcea2dfb4d8022688c497382b33d0 100644 (file)
@@ -108,9 +108,6 @@ mod repo_finder_result;
 #[cfg(any(feature = "v2018_6", feature = "dox"))]
 pub use self::repo_finder_result::RepoFinderResult;
 
-mod repo_transaction_stats;
-pub use self::repo_transaction_stats::RepoTransactionStats;
-
 mod enums;
 pub use self::enums::DeploymentUnlockedState;
 pub use self::enums::GpgSignatureAttr;
diff --git a/rust-bindings/rust/src/auto/repo_transaction_stats.rs b/rust-bindings/rust/src/auto/repo_transaction_stats.rs
deleted file mode 100644 (file)
index ed91ba6..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-// This file was generated by gir (https://github.com/gtk-rs/gir)
-// from gir-files (https://github.com/gtk-rs/gir-files)
-// DO NOT EDIT
-
-use gobject_sys;
-use ostree_sys;
-
-glib_wrapper! {
-    #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
-    pub struct RepoTransactionStats(Boxed<ostree_sys::OstreeRepoTransactionStats>);
-
-    match fn {
-        copy => |ptr| gobject_sys::g_boxed_copy(ostree_sys::ostree_repo_transaction_stats_get_type(), ptr as *mut _) as *mut ostree_sys::OstreeRepoTransactionStats,
-        free => |ptr| gobject_sys::g_boxed_free(ostree_sys::ostree_repo_transaction_stats_get_type(), ptr as *mut _),
-        init => |_ptr| (),
-        clear => |_ptr| (),
-        get_type => || ostree_sys::ostree_repo_transaction_stats_get_type(),
-    }
-}
index 78352506ffd999c068afb7721bb993207e9f184b..d17bddd16afdb9bb918d7a8889b395b7e7321fa9 100644 (file)
@@ -50,6 +50,8 @@ pub use crate::repo::*;
 mod repo_checkout_at_options;
 #[cfg(any(feature = "v2016_8", feature = "dox"))]
 pub use crate::repo_checkout_at_options::*;
+mod repo_transaction_stats;
+pub use repo_transaction_stats::RepoTransactionStats;
 mod se_policy;
 pub use crate::se_policy::*;
 #[cfg(any(feature = "v2020_1", feature = "dox"))]
diff --git a/rust-bindings/rust/src/repo_transaction_stats.rs b/rust-bindings/rust/src/repo_transaction_stats.rs
new file mode 100644 (file)
index 0000000..578b429
--- /dev/null
@@ -0,0 +1,48 @@
+use gobject_sys;
+use ostree_sys;
+
+glib_wrapper! {
+    /// A list of statistics for each transaction that may be interesting for reporting purposes.
+    #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
+    pub struct RepoTransactionStats(Boxed<ostree_sys::OstreeRepoTransactionStats>);
+
+    match fn {
+        copy => |ptr| gobject_sys::g_boxed_copy(ostree_sys::ostree_repo_transaction_stats_get_type(), ptr as *mut _) as *mut ostree_sys::OstreeRepoTransactionStats,
+        free => |ptr| gobject_sys::g_boxed_free(ostree_sys::ostree_repo_transaction_stats_get_type(), ptr as *mut _),
+        init => |_ptr| (),
+        clear => |_ptr| (),
+        get_type => || ostree_sys::ostree_repo_transaction_stats_get_type(),
+    }
+}
+
+impl RepoTransactionStats {
+    /// The total number of metadata objects in the repository after this transaction has completed.
+    pub fn get_metadata_objects_total(&self) -> usize {
+        self.0.metadata_objects_total as usize
+    }
+
+    /// The number of metadata objects that were written to the repository in this transaction.
+    pub fn get_metadata_objects_written(&self) -> usize {
+        self.0.metadata_objects_written as usize
+    }
+
+    /// The total number of content objects in the repository after this transaction has completed.
+    pub fn get_content_objects_total(&self) -> usize {
+        self.0.content_objects_total as usize
+    }
+
+    /// The number of content objects that were written to the repository in this transaction.
+    pub fn get_content_objects_written(&self) -> usize {
+        self.0.content_objects_written as usize
+    }
+
+    /// The amount of data added to the repository, in bytes, counting only content objects.
+    pub fn get_content_bytes_written(&self) -> u64 {
+        self.0.content_bytes_written
+    }
+
+    /// The amount of cache hits during this transaction.
+    pub fn get_devino_cache_hits(&self) -> usize {
+        self.0.devino_cache_hits as usize
+    }
+}